/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vicarvision;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

/**
 *
 * @author User
 */
public class apidecrypt {

    public static String[] decrypt(byte[] data, int count) throws UnsupportedEncodingException, ParserConfigurationException, SAXException, IOException {
        String[] output_string= new String[count];
       // String[] myStringArray = new String[3]
        data = Arrays.copyOfRange(data, 40, count);
        String output = new String(data);
        DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
        DocumentBuilder b = f.newDocumentBuilder();
        Document doc = b.parse(new ByteArrayInputStream(output.getBytes("UTF-8")));
        NodeList classification_Value = doc.getElementsByTagName("ClassificationValue");
        for (int i = 0; i < classification_Value.getLength(); i++) {
            Element label = (Element) classification_Value.item(i);
            Node title_label = label.getElementsByTagName("Label").item(0);
            //System.out.println(title_label.getTextContent());

            Element value = (Element) classification_Value.item(i);
            Node title_value = value.getElementsByTagName("float").item(0);
            //System.out.println(title_label.getTextContent());
            output_string[i] = title_label.getTextContent() + "" + title_value.getTextContent();
           // return output_string[];
        }
        return output_string;
    }
}
